package gaileenchess;

import java.util.LinkedList;

public class King extends Piece
{
    public King(Common.Side s, int r, int c)
    {
        super(s, Type.KING, r, c);
    }
    
    public boolean isValidMove(Common.Side playerSide, Board board, Board.Position pos1, Board.Position pos2)
    {
        Board.Position diff = pos1.diff(pos2);
        return (Math.abs(diff.row) <= 1 && Math.abs(diff.column) <= 1);
    }

    public void getValidMoves(Common.Side playerSide, Board board, LinkedList<Board.Position.Move> pieces, boolean check, int player)
    {
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(1, 1), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(1, -1), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(-1, 1), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(-1, -1), 1, check, player);
        
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(1, 0), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(0, 1), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(-1, 0), 1, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(0, -1), 1, check, player);
    }
}
